<!-- Web Upload to check user name, password PHP File -->
<!-- Reveions History ...
	Rev 1.00 at 2015/06/07 by Max Yin:
		1. First time create
	Rev 1.01 at 2015/07/08 by Max Yin:
		1. 由標楷體, 改成新細明體
-->
<html>
	<body background="pic/background_06.gif">
	<head>
		<font face="新細明體,time new roman,Arial">
		<meta charset="UTF-8">
	</head>
	<body>
		<center>
			<?php
				require_once('class_package/common.php');
				$login_useramne		= $_POST['accout_username'];
				$login_password		= $_POST['accout_password'];
				$get_prgm_select	= $_POST['prgm_select'];
				
				// To check user name & password limit ...
				if ( $login_useramne == '' || $login_password == '' ) {
					echo "<script>alert('输入的栏位中, 不能为空值, 请重新输入...');history.go(-1);</script>";
					exit();
				}
				
				// To check MySQL exist the account user name and password or not?
				$get_query_result = account_search_result($login_useramne);
				if ( !is_array($get_query_result) ) {
					echo "<script>alert('查无此帐号/密码? 请检查后,重新输入...');history.go(-1);</script>";
					exit();
				}
				
				$get_query_password = AnalyzeMySqlStr($get_query_result,'password');
				if ( $login_password != $get_query_password ) {
					echo "<script>alert('帐号/密码错误! 请重新输入...');history.go(-1);</script>";
					exit();
				}
				
				switch ( $get_prgm_select ) {
					case '捞板程式':
						$webdl_wsid	='ROUTER';
						break;
					case 'WS-PROFILE程式':
						$webdl_wsid	='WS-PROFILE';
						break;
					case 'ESD程式':
						$webdl_wsid	='ESD';
						break;
					default:
						break;
				}
				
				// To search all table ...
				$db_select      = Sql_Download::sql_db;
				$db_table       = Sql_Download::sql_table;
				$table_name2	= Sql_Download::table_name2;	// 'webdl_wsid';
				
				// To search all table ...
				$show_num		= 0;	
				$conn			= '';
				$sql_cmd		= '';
				$rows			= 0;
				$result			= '';
				$conn = mysqli_connect(html::sql_login_host,html::sql_login_user,html::sql_login_pass,$db_select);
				if ( mysqli_connect_errno($conn) ) { 
					echo "<script>alert('MySql资料库连接失败,请联系开发人员,并查明原因...');history.go(-1);</script>";
					exit();
				}
				mysqli_set_charset($conn,'set names utf8');
				
				$sql_cmd = "SELECT * FROM `$db_table` WHERE `$table_name2`='$webdl_wsid'";
				$result = mysqli_query($conn,$sql_cmd);	// 透过 execute_query 对象实例完成查询
				if ( !$result ) { 
					mysqli_close($conn);				// 关闭资料库
					echo "<script>alert('MySql资料库搜寻失败,请跟开发人员查明原因...');history.go(-1);</script>";
					exit();
				}
				
				$rows = mysqli_num_rows($result);		// 返回结果集中栏位的数量。
				if ( $rows == 0 ) { 
					echo "<script>alert('查询不到资料栏位, 请重新建立...');history.go(-1);</script>";
					exit();
				}
				
				echo '<br>
				<table border="2" width="75%">
					<tr bgcolor="#70DB93">
						<th>No.</th>
						<th>工單</th>
						<th>Part Number</th>
						<th>WSID</th>
						<th>TPVER</th>
						<th>线别</th>
						<th>制程别</th>
						<th>Create Date/Time</th>
						<th>Create By</th>
						<th>Description</th>
						<th>Download</th>
					</tr>';
				
				while ( $getArray = mysqli_fetch_array($result,MYSQLI_ASSOC) ) {
					$show_num++;
					$put_pn          = $getArray['webdl_pn'];
					$put_wsid        = $getArray['webdl_wsid'];
					$put_tpver       = $getArray['webdl_tpver'];
					$put_work_order  = $getArray['webdl_work_order'];
					$put_line        = $getArray['webdl_line'];
					$put_panel       = $getArray['webdl_panel'];
					$put_create_date = $getArray['webdl_create_date'];
					$put_creator     = $getArray['webdl_creator'];
					$put_description = $getArray['webdl_description'];
					$put_ftpip       = $getArray['webdl_ftpip'];
					
					echo "
						<tr>
							<th>$show_num</th>
							<th><font size='4' color='#0000FF'><b>$put_work_order</b></font></th>
							<th>$put_pn</th>
							<th>$put_wsid</th>
							<th>$put_tpver</th>
							<th>$put_line</th>
							<th>$put_panel</th>
							<th>$put_create_date</th>
							<th>$put_creator</th>
							<th>$put_description</th>
							<th><a href=$put_ftpip>下 载</a></th>
						</tr>";
				}
				echo '</table><br>';
				mysqli_free_result($result);			// 释放 MySQL $result
				mysqli_close($conn);					// 关闭资料库
				exit();
			?>
		</center>
	</body>
</html>


